package com.jiyang.jyandroid.test01;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.R;

/**
 * Created by jy on 2016/10/24.
 * 渐变背景文本框
 */

public class One_6Activity extends BaseActivity implements View.OnClickListener {
    private EditText etAccount, etPass, etAge, etYear;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test01_c);
        findViewById(R.id.btn).setOnClickListener(this);
        etAccount = (EditText) findViewById(R.id.et_account);
        etPass = (EditText) findViewById(R.id.et_pass);
        etAge = (EditText) findViewById(R.id.et_age);
        etYear = (EditText) findViewById(R.id.et_year);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn) {
            if (etAccount.getText().toString().equals("") ||
                    etPass.getText().toString().equals("")
                    || etAge.getText().toString().equals("") ||
                    etYear.getText().toString().equals("")) {
                Toast.makeText(this, "请将信息填写完整", Toast.LENGTH_SHORT).show();
                if (etAccount.getText().toString().equals("")) {
                    etAccount.setHintTextColor(Color.RED);
                } else
                    etAccount.setHintTextColor(Color.LTGRAY);
                if (etPass.getText().toString().equals("")) {
                    etPass.setHintTextColor(Color.RED);
                } else etPass.setHintTextColor(Color.LTGRAY);
                if (etAge.getText().toString().equals("")) {
                    etAge.setHintTextColor(Color.RED);
                } else etAge.setHintTextColor(Color.LTGRAY);
                if (etYear.getText().toString().equals("")) {
                    etYear.setHintTextColor(Color.RED);
                } else etYear.setHintTextColor(Color.LTGRAY);
            } else {
                Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show();
            }
        }
    }
}
